package flowWIndow.f4;

public class test1493 {
    public static void main(String[] args) {
        int nums[] = {1, 0, 0, 0,0,0,0,0};
        Solution solution = new Solution();
        int max = solution.longestSubarray(nums);
        System.out.println(max);
    }
}
class Solution {
    public int longestSubarray(int[] nums) {
        int len =nums.length;
        int delete=1;
        int l=0,r=0;
        while(r<len){
            if(nums[r++]==0){
                delete--;
            }
            if(delete<0&&nums[l++]==0){
                delete++;
            }
        }
        return r-l-1;
    }
}
